package activemq;

import utils.ActiveMq;

import javax.jms.*;

public class ActiveMqProducer {
    public void send(String message) throws JMSException {
        Connection connection = ActiveMq.getConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic(ActiveMq.TOPIC_NAME);
        MessageProducer producer = session.createProducer(topic);
        TextMessage textMessage = session.createTextMessage(message);
        producer.send(textMessage);
        producer.close();
        session.close();
        connection.close();
    }

}
